import { PartialType } from '@nestjs/mapped-types'
import { RegisterDto } from './register.dto'
import { IsNotEmpty, Matches } from 'class-validator'
import { Existsable } from '../../validate/Existsable'

export class LoginDto extends PartialType(RegisterDto) {
	@IsNotEmpty({ message: '用户名不能为空' })
	@Matches(/^[a-zA-Z0-9.@]{3,20}$/, { message: '用户名格式错误, 且长度在3-20个字符' })
	@Existsable('user', ['username', 'email', 'mobile'], { message: '账号不存在' })
	username: string

	@IsNotEmpty({ message: '密码不能为空' })
	password: string
}
